home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 February / Ahoy_Magazine_87-02_1987_Double_L_Side_B.d64 / comal article < prev    next >
Text File  |  2022-10-26  |  9KB  |  322 lines

  1. COMAL AND YOU - For Beginners Only
  2. by David Stidolph
  3.  
  4. WHY LEARN TO PROGRAM?
  5.  
  6. The many commercial computer programs
  7. available today are more than
  8. sufficient for most people's needs.
  9. If word processors, spread sheets,
  10. and data base managers are all your
  11. computer is used for, learning to
  12. program would be a waste of time.
  13.  
  14. For some, however, a goal is being
  15. able to learn something new...
  16. something that can control that
  17. mysterious box called a computer.
  18. There's nothing like the feeling of
  19. accomplishment when you type in your
  20. first working program. Also,
  21. familiarity with computers and
  22. programming helps ease the sense of
  23. helplessness most people get when
  24. dealing with computers. (How did you
  25. feel the first time you got a
  26. computerized bill?) This article is
  27. for people who have made the decision
  28. to not only learn about computers,
  29. but to learn programming as well.
  30.  
  31. WHAT IS A COMPUTER LANGUAGE?
  32.  
  33. Computers work with a language of
  34. zeros and ones called machine code.
  35. This is as difficult to use as it
  36. sounds, and few programmers now work
  37. directly in machine code. They choose
  38. instead to use computer "languages".
  39. These range from low level languages
  40. like assembly code, where the words
  41. merely represent individual machine
  42. code instructions, to high level
  43. languages which look more like
  44. English. Compare the following two
  45. programs:
  46.  
  47. ASSEMBLY CODE
  48. -------------
  49.  
  50.        * =  START
  51.        LDY  #$00
  52. LP     LDA  STRING,Y
  53.        BEQ  ENDLP
  54.        JSR  OUTPUT
  55.        INY
  56.        BNE  LP
  57.        BEQ  ENDLP
  58.        .BYT 'This is a string',13,0
  59. ENDLP  <...>  ; rest of program code
  60.  
  61. COMAL
  62. -----
  63.  
  64. PRINT "This is a string"
  65.  
  66. As you can see, the statement written
  67. in COMAL is shorter and much more
  68. readable. Although the computer will
  69. seem to understand COMAL statements
  70. and programs, the computer itself
  71. only understands machine code. COMAL,
  72. the language, is a machine code
  73. program. It must be loaded into your
  74. computer before you can write, edit,
  75. or run COMAL programs. Think of the
  76. language as a translater between you
  77. and the computer. This means you
  78. don't have to learn machine code -
  79. you only have to make sure that COMAL
  80. is in the machine before you can run
  81. your COMAL programs.
  82.  
  83. WHY LEARN COMAL?
  84.  
  85. Since BASIC comes with most personal
  86. computers today, many people think
  87. that it is the best computer language
  88. to learn. Not so. BASIC is
  89. implemented on so many computers
  90. because it is the easiest language to
  91. write. It has the fewest commands,
  92. and NO definite standard to follow.
  93. This means that a BASIC program
  94. written on one computer may NOT run
  95. on another computer. BASIC does,
  96. however, have one good feature; it
  97. will let you type in a short program
  98. and see it execute as soon as you
  99. type the word RUN. Text editors or
  100. elaborate compiler commands are not
  101. necessary (Most other high level
  102. languages like Pascal, FORTRAN and
  103. COBOL require them). This makes BASIC
  104. seem like a easy-to-learn language
  105. for everyone.
  106.  
  107. COMAL started with this idea of
  108. interactive work with the programmer,
  109. then added to it. COMAL has
  110. structures such as WHILE, REPEAT, and
  111. FOR loops, multi-line IF-THEN-ELSE
  112. statements, a CASE statement
  113. (similiar to a multiple choice
  114. question), and named PROCedures and
  115. FUNCtions complete with parameters.
  116. These structures are similiar those
  117. in "professional" languages like
  118. Pascal. COMAL also has the turtle
  119. graphics made famous by Logo. COMAL
  120. is now the language taught in the
  121. schools of 5 European countries.
  122. COMAL is easier to learn than BASIC,
  123. and teaches the idea of structured
  124. programing necessary with modern
  125. computer languages.
  126.  
  127. HOW DO I GET COMAL?
  128.  
  129. Congratulations, COMAL is included on
  130. this Ahoy disk. To use COMAL, follow
  131. these steps:
  132.  
  133. 1. Type LOAD ":*",8
  134.    Type RUN
  135.    This puts you in Ahoy's main menu.
  136. 2. Choose the "COMAL 64 BOOT" option.
  137.    This will give you COMAL's
  138.    introductory screen. You will be
  139.    given some COMAL information and
  140.    then asked if you want error
  141.    messages in memory. Hit the return
  142.    key for the default answer of yes.
  143. 3. After a short wait, you will be
  144.    put in a COMAL program displaying
  145.    another menu. This will allow you
  146.    to run the COMAL programs on this
  147.    disk, or to read articles such as
  148.    the one you are reading now. If
  149.    you want to enter the COMAL editor
  150.    to write your own programs, simply
  151.    enter the "QUIT THIS MENU" option.
  152. 4. If you are already in COMAL, but
  153.    want to re-enter the menu from
  154.    step 3, all you need to do is type
  155.    in:
  156.  
  157.    CHAIN "hi"
  158.  
  159.    assuming the Ahoy disk is in the
  160.    disk drive.
  161.  
  162. NOTE: COMAL and the COMAL programs on
  163. this disk are copyrighted, but we
  164. give you permission to give copies
  165. away. This permission does not apply
  166. to the BASIC programs from Ahoy.
  167.  
  168. WHAT DO I DO WITH COMAL?
  169.  
  170. Since COMAL is on this Ahoy disk, you
  171. can learn to write readable programs.
  172. One way to learn is to first look at
  173. other peoples' work. I will detail
  174. certain commands now so that you can
  175. do just that. The commands will be
  176. listed in UPPERCASE, but type them in
  177. with unshifted letters.
  178.  
  179. CAT
  180.  
  181. This command will show you what files
  182. are on the disk in the disk drive.
  183. The disk drive sends the disk
  184. DIRECTORY to the computer, and COMAL
  185. prints it on the screen. The actual
  186. listing shows more than just file
  187. names. It shows how big they are,
  188. their names, and the file type. Each
  189. entry in the directory is called a
  190. file, and there are four types of
  191. files - PRG (program), SEQ
  192. (sequential - data files), REL
  193. (random - also data files), and USR
  194. (special files). Unlike the BASIC
  195. commands:
  196.  
  197.   LOAD "$",8
  198.   LIST
  199.  
  200. COMAL will not erase the program in
  201. memory while showing a directory of a
  202. disk. You can slow the scrolling
  203. lines by holding down the CTRL key on
  204. the upper left hand side of the
  205. keyboard, or stop it by pressing the
  206. RUN/STOP key (right below the CTRL
  207. key). If you happen to have a dual
  208. drive (a two drive unit) you can add
  209. a '0' or a '1' after the command:
  210.  
  211.   cat 0    (This is for drive 0)
  212.   cat 1    (This is for drive 1)
  213.  
  214. LOAD
  215.  
  216. Once you know what is on a disk, you
  217. can load COMAL programs into memory
  218. with this command. It is similar to
  219. the BASIC LOAD command, except you no
  220. longer need to type the comma 8. The
  221. following is an example of loading a
  222. program called "filename" from the
  223. disk drive:
  224.  
  225.   load "filename"
  226.  
  227. Only PRG type files can be loaded. Be
  228. careful, because other languages,
  229. like BASIC, also store their programs
  230. as PRG files. COMAL 0.14 will attempt
  231. to load any PRG type file you ask it
  232. to. If you are not sure whether or
  233. not a program was written in COMAL
  234. 0.14, load the program and LIST it.
  235. Only COMAL 0.14 programs can be
  236. listed, any other type of program
  237. (BASIC, COMAL 2.0, etc) will not
  238. list. DO NOT RUN PROGRAMS WHICH WON'T
  239. LIST. If you do, COMAL will become
  240. confused and stop functioning. The
  241. only thing to do after this has
  242. happened is to turn the computer off
  243. and reload COMAL.
  244.  
  245. LIST
  246.  
  247. Once a COMAL program is in memory,
  248. you will want to be able to see it.
  249. The command LIST will do just that,
  250. it will list the program to the
  251. screen. The first thing you will
  252. notice is you will want to slow or
  253. stop the listing (so you can study
  254. it). Just as with the catalog
  255. command, you can use the CTRL key to
  256. slow the listing, or the RUN/STOP key
  257. to stop the listing. When LISTing a
  258. PROGRAM, the space bar will pause the
  259. listing.
  260.  
  261. You will notice that each line has a
  262. number in front of it. COMAL uses
  263. them to keep track of the order of
  264. the program lines. The order goes
  265. from low (1) to high (9999). You can
  266. use any line number between.
  267.  
  268. The LIST command can also be used to
  269. show just part of a program. The
  270. following are some examples to do
  271. just that:
  272.  
  273.  list         (all lines)
  274.  list 100-500 (from line 100 to 500)
  275.  list 100-    (from line 100 to end)
  276.  list -500    (from beginning to 500)
  277.  
  278. RUN
  279.  
  280. When the program you want has been
  281. loaded into memory, you start the
  282. program with the command RUN. The
  283. computer does a quick scan of the
  284. program to make sure it seems
  285. correct, and starts executing with
  286. the first line of the program. If an
  287. error occurs while the program is
  288. running, the program will stop
  289. executing. COMAL will print what the
  290. problem is and the line number it
  291. occured on.
  292.  
  293. MAKING ERRORS
  294.  
  295. There is a very good chance that you
  296. will make typing errors while trying
  297. these commands. COMAL checks each
  298. line you type for errors, and if it
  299. cannot understand what you typed, it
  300. will stop and give you an error
  301. message. It might go out to the disk
  302. drive and get the error message, or
  303. it might just print the message
  304. itself (that depends on your choice
  305. to have error messages in memory or
  306. not). If you get an error, COMAL will
  307. put the cursor on the part of the
  308. line it is having trouble with so
  309. DON'T PANIC. Just make the correction
  310. and press the RETURN key again.
  311.  
  312. STATUS
  313.  
  314. If the red light on the disk drive
  315. starts blinking on and off while
  316. COMAL just sits there waiting for you
  317. to type something, try typing in the
  318. STATUS command. This will print disk
  319. error message to the screen. Check
  320. your disk drive manual for more
  321. information if necessary.
  322.